In [11]:
import os
import glob
import numpy as np
import medleydb as mdb
from medleydb import mix
import sox
import shutil

Make MedleyDB training data


In [7]:
MDB_AUDIO_DIR = '/Users/rachelbittner/Documents/VocalAnnotations_MDB/audio/'
MDB_ANNOT_DIR = '/Users/rachelbittner/Documents/VocalAnnotations_MDB/annotations'

In [23]:
mtracks = mdb.load_melody_multitracks()
for mtrack in mtracks:
    print(mtrack.track_id)

    if mtrack.predominant_stem.instrument not in mix.VOCALS:
        print "no vocals...skipping"
        print ""
        continue

    output_path = os.path.join(MDB_AUDIO_DIR, '{}_vocal.wav'.format(mtrack.track_id))
    print([(i, v.instrument) for i, v in mtrack.stems.items()])
        
    need_remix = False
    stem_indices = mtrack.stems.keys()
    stem_indices.remove(mtrack.predominant_stem.stem_idx)
    for i in stem_indices:
        if (mtrack.stems[i].instrument in mix.VOCALS):
            need_remix = True

    if need_remix:
        print("needs remix")
        mix_stems = [i for i, v in mtrack.stems.items() if v.instrument not in mix.VOCALS]
        mix_stems.append(mtrack.predominant_stem.stem_idx)
        mix.mix_multitrack(mtrack, output_path, stem_indices=mix_stems)
    else:
        print("using orignal mix")
        shutil.copy(mtrack.mix_path, output_path)

    melody1_fpath = os.path.join(mtrack.annotation_dir, mdb.multitrack._MELODY1_FMT % mtrack.track_id)
    annotation_fpath = os.path.join(MDB_ANNOT_DIR, '{}_vocal.csv'.format(mtrack.track_id))
    shutil.copy(melody1_fpath, annotation_fpath)
    print ""


AClassicEducation_NightOwl
[(1, 'electric bass'), (2, 'drum set'), (3, 'distorted electric guitar'), (4, 'distorted electric guitar'), (5, 'clean electric guitar'), (6, 'distorted electric guitar'), (7, 'distorted electric guitar'), (8, 'male singer'), (9, 'synthesizer'), (10, 'vocalists'), (11, 'tambourine'), (12, 'fx/processed sound'), (13, 'male singer')]
needs remix

AimeeNorwich_Child
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'female singer'), (5, 'vocalists'), (6, 'piano'), (7, 'acoustic guitar')]
needs remix

AimeeNorwich_Flying
no vocals...skipping

AlexanderRoss_GoodbyeBolero
[(1, 'acoustic guitar'), (2, 'clean electric guitar'), (3, 'clean electric guitar'), (4, 'electric bass'), (5, 'drum set'), (6, 'male singer'), (7, 'brass section'), (8, 'viola section'), (9, 'harmonica')]
using orignal mix

AlexanderRoss_VelvetCurtain
[(1, 'acoustic guitar'), (2, 'clean electric guitar'), (3, 'clean electric guitar'), (4, 'electric bass'), (5, 'drum set'), (6, 'male singer'), (7, 'brass section'), (8, 'string section'), (9, 'vocalists'), (10, 'clean electric guitar')]
needs remix

AmarLal_Rest
no vocals...skipping

AmarLal_SpringDay1
no vocals...skipping

Auctioneer_OurFutureFaces
[(1, 'banjo'), (2, 'electric bass'), (3, 'vocalists'), (4, 'drum set'), (5, 'clean electric guitar'), (6, 'horn section'), (7, 'vibraphone'), (8, 'male singer'), (9, 'auxiliary percussion'), (10, 'piano')]
needs remix

AvaLuna_Waterduct
[(1, 'electric bass'), (2, 'synthesizer'), (3, 'vocalists'), (4, 'drum set'), (5, 'distorted electric guitar'), (6, 'fx/processed sound'), (7, 'vibraphone'), (8, 'male singer')]
needs remix

BigTroubles_Phantom
[(1, 'electric bass'), (2, 'drum set'), (3, 'distorted electric guitar'), (4, 'male singer'), (5, 'distorted electric guitar'), (6, 'male singer'), (7, 'distorted electric guitar')]
needs remix

BrandonWebster_DontHearAThing
[(1, 'male speaker'), (2, 'female singer'), (3, 'piano')]
needs remix

BrandonWebster_YesSirICanFly
[(1, 'piano'), (2, 'male singer')]
using orignal mix

CelestialShore_DieForUs
[(1, 'male singer'), (2, 'female singer'), (3, 'electric bass'), (4, 'synthesizer'), (5, 'clean electric guitar'), (6, 'drum set'), (7, 'tack piano'), (8, 'clean electric guitar'), (9, 'synthesizer')]
needs remix

ChrisJacoby_BoothShotLincoln
no vocals...skipping

ChrisJacoby_PigsFoot
no vocals...skipping

ClaraBerryAndWooldog_AirTraffic
[(1, 'drum set'), (2, 'timpani'), (3, 'electric bass'), (4, 'clean electric guitar'), (5, 'lap steel guitar'), (6, 'piano'), (7, 'female singer'), (8, 'female singer')]
needs remix

ClaraBerryAndWooldog_Boys
[(1, 'drum set'), (2, 'snare drum'), (3, 'brass section'), (4, 'timpani'), (5, 'piano'), (6, 'female singer'), (7, 'vocalists'), (8, 'tenor saxophone'), (9, 'tack piano')]
needs remix

ClaraBerryAndWooldog_Stella
[(1, 'drum set'), (2, 'auxiliary percussion'), (3, 'vibraphone'), (4, 'electric bass'), (5, 'piano'), (6, 'synthesizer'), (7, 'female singer'), (8, 'vocalists')]
needs remix

ClaraBerryAndWooldog_TheBadGuys
[(1, 'piano'), (2, 'female singer')]
using orignal mix

ClaraBerryAndWooldog_WaltzForMyVictims
[(1, 'drum set'), (2, 'electric bass'), (3, 'piano'), (4, 'glockenspiel'), (5, 'female singer')]
using orignal mix

Creepoid_OldTree
[(1, 'vocalists'), (2, 'electric bass'), (3, 'fx/processed sound'), (4, 'drum set'), (5, 'distorted electric guitar'), (6, 'distorted electric guitar'), (7, 'male singer'), (8, 'male singer'), (9, 'male singer'), (10, 'auxiliary percussion')]
needs remix

CroqueMadame_Oil
no vocals...skipping

CroqueMadame_Pilot
no vocals...skipping

Debussy_LenfantProdigue
[(1, 'male singer'), (2, 'piano')]
using orignal mix

DreamersOfTheGhetto_HeavyLove
[(1, 'electric bass'), (2, 'vocalists'), (3, 'fx/processed sound'), (4, 'auxiliary percussion'), (5, 'drum set'), (6, 'male singer'), (7, 'synthesizer'), (8, 'female singer'), (9, 'synthesizer')]
needs remix

EthanHein_1930sSynthAndUprightBass
no vocals...skipping

EthanHein_GirlOnABridge
no vocals...skipping

FacesOnFilm_WaitingForGa
[(1, 'acoustic guitar'), (2, 'electric bass'), (3, 'male singer'), (4, 'drum set'), (5, 'clean electric guitar'), (6, 'distorted electric guitar'), (7, 'synthesizer'), (8, 'vibraphone'), (9, 'vocalists'), (10, 'vocalists'), (11, 'auxiliary percussion')]
needs remix

FamilyBand_Again
[(1, 'electric bass'), (2, 'vocalists'), (3, 'drum set'), (4, 'acoustic guitar'), (5, 'clean electric guitar'), (6, 'distorted electric guitar'), (7, 'lap steel guitar'), (8, 'lap steel guitar'), (9, 'female singer'), (10, 'melodica'), (11, 'auxiliary percussion')]
needs remix

Handel_TornamiAVagheggiar
[(1, 'female singer'), (2, 'piano')]
using orignal mix

HeladoNegro_MitadDelMundo
[(1, 'fx/processed sound'), (2, 'synthesizer'), (3, 'male singer'), (4, 'drum machine'), (5, 'synthesizer'), (6, 'synthesizer'), (7, 'vibraphone'), (8, 'male singer'), (9, 'synthesizer'), (10, 'tack piano')]
needs remix

HezekiahJones_BorrowedHeart
[(1, 'acoustic guitar'), (2, 'vocalists'), (3, 'banjo'), (4, 'electric bass'), (5, 'vibraphone'), (6, 'vocalists'), (7, 'cymbal'), (8, 'auxiliary percussion'), (9, 'drum set'), (10, 'male singer'), (11, 'violin section'), (12, 'lap steel guitar')]
needs remix

HopAlong_SisterCities
[(1, 'acoustic guitar'), (2, 'electric bass'), (3, 'vocalists'), (4, 'drum set'), (5, 'synthesizer'), (6, 'distorted electric guitar'), (7, 'female singer'), (8, 'distorted electric guitar')]
needs remix

InvisibleFamiliars_DisturbingWildlife
[(1, 'electric bass'), (2, 'claps'), (3, 'trumpet section'), (4, 'drum set'), (5, 'clean electric guitar'), (6, 'shaker'), (7, 'vocalists'), (8, 'vocalists'), (9, 'male singer'), (10, 'tack piano')]
needs remix

JoelHelander_Definition
no vocals...skipping

JoelHelander_ExcessiveResistancetoChange
no vocals...skipping

JoelHelander_IntheAtticBedroom
no vocals...skipping

KarimDouaidy_Hopscotch
no vocals...skipping

KarimDouaidy_Yatora
no vocals...skipping

LizNelson_Coldwar
[(1, 'acoustic guitar'), (2, 'female singer')]
using orignal mix

LizNelson_ImComingHome
[(1, 'female singer'), (2, 'female singer'), (3, 'female singer'), (4, 'female singer')]
needs remix

LizNelson_Rainfall
[(1, 'female singer'), (2, 'female singer'), (3, 'female singer'), (4, 'acoustic guitar'), (5, 'clean electric guitar')]
needs remix

MatthewEntwistle_DontYouEver
[(1, 'double bass'), (2, 'piano'), (3, 'brass section'), (4, 'drum set'), (5, 'violin section'), (6, 'violin section'), (7, 'male singer')]
using orignal mix

MatthewEntwistle_FairerHopes
no vocals...skipping

MatthewEntwistle_ImpressionsOfSaturn
no vocals...skipping

MatthewEntwistle_Lontano
[(1, 'piano'), (2, 'female singer')]
using orignal mix

MatthewEntwistle_TheArch
no vocals...skipping

MatthewEntwistle_TheFlaxenField
no vocals...skipping

Meaxic_TakeAStep
[(1, 'electric bass'), (2, 'clean electric guitar'), (3, 'distorted electric guitar'), (4, 'male singer'), (5, 'drum set'), (6, 'vocalists'), (7, 'vocalists'), (8, 'vocalists')]
needs remix

Meaxic_YouListen
[(1, 'male singer'), (2, 'vocalists'), (3, 'acoustic guitar'), (4, 'electric bass'), (5, 'clean electric guitar'), (6, 'distorted electric guitar'), (7, 'drum set')]
needs remix

MichaelKropf_AllGoodThings
no vocals...skipping

Mozart_BesterJungling
[(1, 'female singer'), (2, 'piano')]
using orignal mix

Mozart_DiesBildnis
[(1, 'male singer'), (2, 'piano')]
using orignal mix

MusicDelta_80sRock
[(1, 'drum set'), (2, 'electric bass'), (3, 'distorted electric guitar'), (4, 'male singer')]
using orignal mix

MusicDelta_Beatles
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'clean electric guitar'), (5, 'acoustic guitar'), (6, 'clean electric guitar'), (7, 'male singer'), (8, 'female singer')]
needs remix

MusicDelta_BebopJazz
no vocals...skipping

MusicDelta_Beethoven
no vocals...skipping

MusicDelta_Britpop
[(1, 'drum set'), (2, 'electric bass'), (3, 'distorted electric guitar'), (4, 'clean electric guitar'), (5, 'clean electric guitar'), (6, 'clean electric guitar'), (7, 'female singer'), (8, 'female singer')]
needs remix

MusicDelta_ChineseChaoZhou
no vocals...skipping

MusicDelta_ChineseDrama
no vocals...skipping

MusicDelta_ChineseHenan
no vocals...skipping

MusicDelta_ChineseJiangNan
no vocals...skipping

MusicDelta_ChineseXinJing
no vocals...skipping

MusicDelta_ChineseYaoZu
no vocals...skipping

MusicDelta_CoolJazz
no vocals...skipping

MusicDelta_Country1
[(1, 'drum set'), (2, 'electric bass'), (3, 'acoustic guitar'), (4, 'acoustic guitar'), (5, 'male singer')]
using orignal mix

MusicDelta_Country2
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'clean electric guitar'), (5, 'female singer')]
using orignal mix

MusicDelta_Disco
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'male singer')]
using orignal mix

MusicDelta_FreeJazz
no vocals...skipping

MusicDelta_FunkJazz
no vocals...skipping

MusicDelta_FusionJazz
no vocals...skipping

MusicDelta_Gospel
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'clean electric guitar'), (5, 'claps'), (6, 'female singer')]
using orignal mix

MusicDelta_GriegTrolltog
no vocals...skipping

MusicDelta_Grunge
[(1, 'drum set'), (2, 'electric bass'), (3, 'distorted electric guitar'), (4, 'distorted electric guitar'), (5, 'male singer')]
using orignal mix

MusicDelta_Hendrix
[(1, 'drum set'), (2, 'electric bass'), (3, 'distorted electric guitar'), (4, 'male singer')]
using orignal mix

MusicDelta_InTheHalloftheMountainKing
no vocals...skipping

MusicDelta_LatinJazz
no vocals...skipping

MusicDelta_ModalJazz
no vocals...skipping

MusicDelta_Pachelbel
no vocals...skipping

MusicDelta_Punk
[(1, 'drum set'), (2, 'electric bass'), (3, 'distorted electric guitar'), (4, 'male singer')]
using orignal mix

MusicDelta_Reggae
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'male singer')]
using orignal mix

MusicDelta_Rock
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'clean electric guitar'), (5, 'male singer')]
using orignal mix

MusicDelta_Rockabilly
[(1, 'drum set'), (2, 'electric bass'), (3, 'distorted electric guitar'), (4, 'clean electric guitar'), (5, 'female singer')]
using orignal mix

MusicDelta_Shadows
no vocals...skipping

MusicDelta_SpeedMetal
no vocals...skipping

MusicDelta_SwingJazz
no vocals...skipping

MusicDelta_Vivaldi
no vocals...skipping

MusicDelta_Zeppelin
no vocals...skipping

NightPanther_Fire
[(1, 'electric bass'), (2, 'vocalists'), (3, 'vocalists'), (4, 'drum machine'), (5, 'drum set'), (6, 'brass section'), (7, 'male singer'), (8, 'auxiliary percussion'), (9, 'string section'), (10, 'synthesizer'), (11, 'synthesizer'), (12, 'synthesizer')]
needs remix

Phoenix_BrokenPledgeChicagoReel
no vocals...skipping

Phoenix_ColliersDaughter
no vocals...skipping

Phoenix_ElzicsFarewell
no vocals...skipping

Phoenix_LarkOnTheStrandDrummondCastle
no vocals...skipping

Phoenix_ScotchMorris
no vocals...skipping

Phoenix_SeanCaughlinsTheScartaglen
no vocals...skipping

PortStWillow_StayEven
[(1, 'vocalists'), (2, 'cymbal'), (3, 'drum set'), (4, 'drum set'), (5, 'clean electric guitar'), (6, 'clean electric guitar'), (7, 'clean electric guitar'), (8, 'male singer'), (9, 'piano'), (10, 'electric bass'), (11, 'fx/processed sound')]
needs remix

PurlingHiss_Lolita
[(1, 'electric bass'), (2, 'drum set'), (3, 'distorted electric guitar'), (4, 'distorted electric guitar'), (5, 'tambourine'), (6, 'vocalists')]
using orignal mix

Schubert_Erstarrung
[(1, 'male singer'), (2, 'piano')]
using orignal mix

Schumann_Mignon
[(1, 'piano'), (2, 'female singer')]
using orignal mix

SecretMountains_HighHorse
[(1, 'electric bass'), (2, 'vocalists'), (3, 'cymbal'), (4, 'drum set'), (5, 'clean electric guitar'), (6, 'fx/processed sound'), (7, 'piano'), (8, 'synthesizer'), (9, 'female singer'), (10, 'fx/processed sound')]
needs remix

Snowmine_Curfews
[(1, 'auxiliary percussion'), (2, 'electric bass'), (3, 'male singer'), (4, 'vibraphone'), (5, 'drum set'), (6, 'sampler'), (7, 'clean electric guitar'), (8, 'clean electric guitar'), (9, 'synthesizer'), (10, 'vocalists'), (11, 'tack piano')]
needs remix

StevenClark_Bounty
[(1, 'clean electric guitar'), (2, 'electric bass'), (3, 'vocalists'), (4, 'synthesizer'), (5, 'drum set'), (6, 'synthesizer'), (7, 'male singer'), (8, 'male singer'), (9, 'piano'), (10, 'synthesizer')]
needs remix

StrandOfOaks_Spacestation
[(1, 'electric bass'), (2, 'vocalists'), (3, 'drum set'), (4, 'male singer'), (5, 'auxiliary percussion'), (6, 'piano'), (7, 'synthesizer'), (8, 'tack piano')]
needs remix

SweetLights_YouLetMeDown
[(1, 'acoustic guitar'), (2, 'electric bass'), (3, 'vocalists'), (4, 'synthesizer'), (5, 'claps'), (6, 'drum set'), (7, 'synthesizer'), (8, 'male singer'), (9, 'piano'), (10, 'synthesizer'), (11, 'tack piano'), (12, 'timpani'), (13, 'auxiliary percussion')]
needs remix

TheDistricts_Vermont
[(1, 'electric bass'), (2, 'vocalists'), (3, 'drum set'), (4, 'synthesizer'), (5, 'male singer'), (6, 'clean electric guitar'), (7, 'clean electric guitar')]
needs remix

TheScarletBrand_LesFleursDuMal
[(1, 'drum set'), (2, 'electric bass'), (3, 'clean electric guitar'), (4, 'distorted electric guitar'), (5, 'distorted electric guitar'), (6, 'fx/processed sound'), (7, 'clean electric guitar'), (8, 'male singer')]
using orignal mix

TheSoSoGlos_Emergency
[(1, 'electric bass'), (2, 'vocalists'), (3, 'drum set'), (4, 'distorted electric guitar'), (5, 'male singer'), (6, 'auxiliary percussion'), (7, 'fx/processed sound'), (8, 'synthesizer'), (9, 'acoustic guitar'), (10, 'vibraphone')]
needs remix

Wolf_DieBekherte
[(1, 'female singer'), (2, 'piano')]
using orignal mix


In [ ]:


In [ ]:

Make World Music Validation Set


In [5]:
WORLD_MUSIC_AUDIO_DIR = '/Users/rachelbittner/Documents/VocalAnnotations_Tony/audio/'
WORLD_MUSIC_TONY_DIR = '/Users/rachelbittner/Documents/VocalAnnotations_Tony/tony/'
WORLD_MUSIC_ANNOT_DIR = '/Users/rachelbittner/Documents/VocalAnnotations_Tony/annotations/'
TONY_SCRIPT = '/Users/rachelbittner/Dropbox/MARL/repos/medleydb/scripts/fill_tony_file.py'

In [6]:
for audio_fpath in glob.glob(os.path.join(WORLD_MUSIC_AUDIO_DIR, '*.wav')):
    fname = os.path.basename(audio_fpath).split('.')[0]
    tony_fpath = os.path.join(WORLD_MUSIC_TONY_DIR, "{}.csv".format(fname))
    output_fpath = os.path.join(WORLD_MUSIC_ANNOT_DIR, "{}.csv".format(fname))
    duration = sox.file_info.duration(audio_fpath)
    os.system('python {} {} {} {}'.format(TONY_SCRIPT, tony_fpath, output_fpath, duration))

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: